// 过滤非数字
const filterNoNum = (value, changeVal) => {
    let changeNum = changeVal
    console.log(value);
    const phoneValue = value;
    const str = phoneValue.substr(phoneValue.length - 1, 1);
    const reg = /^[0-9]+.?[0-9]*$/;
    if (!reg.test(str)) {
        console.log('不是数字')
        changeNum = phoneValue.substr(0, phoneValue.length - 1);
    } else {
        console.log('是数字')
    }
    return changeNum;
}
// 判断是否是特殊的iphone手机
const isSpecialIphone = () => {
    // iPhone X、iPhone XS
    const isIPhoneX = /iphone/gi.test(window.navigator.userAgent) && window.devicePixelRatio && window.devicePixelRatio === 3 && window.screen.width === 375 && window.screen.height === 812
    // iPhone XS Max
    const isIPhoneXSMax = /iphone/gi.test(window.navigator.userAgent) && window.devicePixelRatio && window.devicePixelRatio === 3 && window.screen.width === 414 && window.screen.height === 896
    // iPhone XR
    const isIPhoneXR = /iphone/gi.test(window.navigator.userAgent) && window.devicePixelRatio && window.devicePixelRatio === 2 && window.screen.width === 414 && window.screen.height === 896
    if (isIPhoneX || isIPhoneXSMax || isIPhoneXR) {
        return true
    }
    return false
}
// 获取系统类型
const getSystemType = () => {
    console.log('获取系统类型-----')
    return new Promise((resolve) => {
        /* eslint no-else-return: "off" */
        const ua = navigator.userAgent.toLowerCase()
        if (/iphone|ipad|ipod/.test(ua)) {
            resolve('ios')
        } else if (/android/.test(ua)) {
            resolve('android')
        } else {
            resolve('android')
        }
    })
}
export default {
    filterNoNum,
    isSpecialIphone,
    getSystemType,
}
